package org.ehe.finance.voucher.domain;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.ehe.common.mybatis.core.domain.BaseEntity2;

import java.math.BigDecimal;
/**
 * 记账凭证明细实体类
 * @author :zhangnn
 * @className :ErpFinanceVoucherDetail
 * @description: TODO
 * @date 2025-08-25 13:14:08
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("erp_finance_voucher_detail")
public class ErpFinanceVoucherDetail extends BaseEntity2 {
    @Schema(description = "凭证明细ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Schema(description = "凭证主表ID")
    @NotNull(message = "凭证ID不能为空")
    private Long voucherId;

    @Schema(description = "分录号")
    @NotNull(message = "分录号不能为空")
    @Min(value = 1, message = "分录号必须大于0")
    private Integer entryNo;

    @Schema(description = "会计科目ID")
    @NotNull(message = "会计科目不能为空")
    private Long subjectId;

    @Schema(description = "摘要")
    @Size(max = 255, message = "摘要长度不能超过255个字符")
    private String abstractInfo;

    @Schema(description = "借方金额")
    @DecimalMin(value = "0.00", message = "借方金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "借方金额格式不正确")
    private BigDecimal debitAmount = BigDecimal.ZERO;

    @Schema(description = "贷方金额")
    @DecimalMin(value = "0.00", message = "贷方金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "贷方金额格式不正确")
    private BigDecimal creditAmount = BigDecimal.ZERO;

    @Schema(description = "客户ID(辅助核算)")
    private Long customerId;

    @Schema(description = "供应商ID(辅助核算)")
    private Long supplierId;

    @Schema(description = "员工ID(辅助核算)")
    private Long employeeId;

    @Schema(description = "项目ID(辅助核算)")
    private Long projectId;

    @Schema(description = "部门ID(辅助核算)")
    private Long departmentId;

    @Schema(description = "币种ID")
    private Long currencyId;

    @Schema(description = "汇率")
    @DecimalMin(value = "0.0001", message = "汇率必须大于0")
    @Digits(integer = 6, fraction = 4, message = "汇率格式不正确")
    private BigDecimal exchangeRate = new BigDecimal("1.0000");

    @Schema(description = "外币借方金额")
    @DecimalMin(value = "0.00", message = "外币借方金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "外币借方金额格式不正确")
    private BigDecimal foreignDebit = BigDecimal.ZERO;

    @Schema(description = "外币贷方金额")
    @DecimalMin(value = "0.00", message = "外币贷方金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "外币贷方金额格式不正确")
    private BigDecimal foreignCredit = BigDecimal.ZERO;

    @Schema(description = "创建部门")
    private Long createDept;
}
